package cn.mrcode.fd.blog.controller;

import cn.mrcode.fd.blog.common.BaseController;
import cn.mrcode.fd.blog.dto.stat.ArticleStat;
import cn.mrcode.fd.blog.dto.stat.Stat;
import cn.mrcode.fd.blog.task.StatTask;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统计
 * @author : zhuqiang
 * @version : V1.0
 * @date : 2016/2/27 20:03
 */
@Controller
@RequestMapping("/stat")
public class StatController extends BaseController{
    /**
     * 统计文章访问量
     * @param
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/article",method = RequestMethod.POST)
    @ResponseBody
    public String article(ArticleStat articleStat) throws Exception {
        articleStat = (articleStat == null ? new ArticleStat() : articleStat);
        StatTask.deque.add(articleStat);
        return "";
    }
    /**
     * 统计文章访问量
     * @param
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/users",method = RequestMethod.POST)
    @ResponseBody
    public String users(Stat stat) throws Exception {
        stat = (stat == null ? new Stat() : stat);
        StatTask.deque.add(stat);
        return "";
    }
}
